import { Controller, Get, Post, Body, Patch, Param, Delete, Query, Request } from '@nestjs/common';
import { ApiOperation, ApiTags, ApiQuery, ApiBearerAuth } from '@nestjs/swagger';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { Public } from '../auth/decorators/public.decorator';

@ApiBearerAuth()
@ApiTags('用户')
@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  // 列表
  @Get('list')
  @ApiOperation({ summary: '查询', description: '查询' })
  @ApiQuery({ name: 'pageNum', type: Number, required: false, description: '页码' })
  @ApiQuery({ name: 'pageSize', type: Number, required: false, description: '每页几条' })
  findAll(@Query() params: any) {
    return this.userService.findAll(params);
  }

  // 新增、修改
  @Post('add')
  @ApiOperation({ summary: '新增、修改', description: '新增、修改' })
  create(@Body() createUserDto: CreateUserDto) {
    return this.userService.create(createUserDto);
  }

  // 用户详情
  @Get('detail')
  @ApiOperation({ summary: '用户详情', description: '用户详情' })
  @ApiQuery({ name: 'id', type: Number, required: false, description: 'id' })
  detail(@Query() params: any) {
    return this.userService.detail(params);
  }

  // 修改密码
  @Post('eidtPasswrod')
  @ApiOperation({ summary: '修改密码', description: '修改密码' })
  eidtPasswrod(@Body() createUserDto: CreateUserDto) {
    return this.userService.eidtPasswrod(createUserDto);
  }

  // 合约账户信息
  //  total:钱包资产  unrealised_pnl:未实现盈亏
  @Get('futuresAccount')
  @ApiOperation({ summary: '合约账户信息', description: '合约账户信息' })
  async futuresAccount(@Query() params: any) {
    return await this.userService.futuresAccount();
  }

  // 统一账户信息
  @Get('unifiedAccount')
  @ApiOperation({ summary: '统一账户信息', description: '统一账户信息' })
  async unifiedAccount(@Query() params: any) {
    return await this.userService.unifiedAccount();
  }

  // 资金流水
  @Get('fundFlow')
  @ApiOperation({ summary: '资金流水', description: '资金流水' })
  async fundFlow(@Query() params: any) {
    return await this.userService.fundFlow(params);
  }

  @Get('ziChan')
  @ApiOperation({ summary: '资产', description: '资产' })
  async ziChan(@Query() params: any) {
    return await this.userService.ziChan(params);
  }

  @Get('keYongMoney')
  @ApiOperation({ summary: '可用资产', description: '可用资产' })
  async keYongMoney(@Query() params: any) {
    return await this.userService.keYongMoney(params);
  }

  @Public()
  @Get('resetZiChan')
  @ApiOperation({ summary: '重置用户资产和资产时间', description: '重置用户资产和资产时间' })
  async resetZiChan(@Query() params: any) {
    return await this.userService.resetZiChan();
  }

  @Public()
  @Get('resetTSYHZiChan')
  @ApiOperation({ summary: '重置特殊用户资产和资产时间-李四', description: '重置用户资产和资产时间' })
  async resetTSYHZiChan(@Query() params: any) {
    return await this.userService.resetTSYHZiChan();
  }

  @Get('htfundFlow')
  @ApiOperation({ summary: '后台资金流水', description: '后台资金流水' })
  async htfundFlow(@Query() params: any) {
    return await this.userService.htfundFlow(params);
  }

  @Get('zhiMaYingKui')
  @ApiOperation({ summary: '芝麻盈亏', description: '芝麻盈亏' })
  async zhiMaYingKui(@Query() params: any) {
    return await this.userService.zhiMaYingKui(params);
  }

  @Public()
  @Get('editTongbuTime')
  @ApiOperation({ summary: '批量修改同步时间' })
  editTongbuTime(@Query() params: any) {
    return this.userService.editTongbuTime();
  }
}
